<!-- 从show页登录成功后取得vid 并跳转到登录模态框--> 
<meta charset="UTF-8">
 <script>
 function func(vid){
	document.getElementById("videoid").value=vid;
   document.getElementById("login").modal();
	}
 </script>
<?php
 include_once('dbConn.php');
  //连接数据库		
 connect();
$vid=$_POST["vid"];
session_start();
//根据user的session值取得uid
if(isset($_SESSION["user"]))
{
$uname=$_SESSION["user"];
$sql1="select uid from users where uname='$uname'";
$rs1=mysql_query($sql1)or die('查询1失败！'.mysql_error());   
$row1=mysql_fetch_assoc($rs1);
$uid=$row1["uid"];
echo "uid=".$uid;
	}
$content=$_POST["content"];
$sql2="insert into comments values(null,'$content',now(),$uid,$vid)";
echo $sql2;
$rs2=mysql_query($sql2)or die('查询2失败！'.mysql_error());   
if($rs2>0){
echo "<h2>"."本次留言成功"."</h2>";
header("location:show.php?vid=$vid");
}
else{
	echo "本次留言失败";
}
?>
